﻿using deviceManage.Models;
using deviceManage.VO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace deviceManage.Service
{
    /// <summary>
    /// 机房管理
    /// </summary>
    public class RoomService
    {
        private readonly DeviceCtx _context;
        public RoomService(DeviceCtx _context)
        {
            this._context = _context;
        }

        public List<Room> GetList()
        {
            return _context.Room.Where(p => p.Deleted == 0).OrderBy(p => p.SortOrder).ToList();
        }


        public Room GetById(string id)
        {
            return _context.Room.Single(p => p.Id == id);
        }

        public void update(Room device)
        {
            _context.Room.Update(device);
            _context.SaveChanges();
        }

        public void Delete(string id)
        {
            var d = this.GetById(id);
            d.Deleted = 1;            
            _context.Room.Update(d);
            _context.SaveChanges();
        }

       
        
    }
}
